package errs

import (
	codes "google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
	common "vben-common"
)

func GrpcError(err *BError) error {
	return status.Error(codes.Code(err.Code), err.Msg)
}

// ParseGrpcError
// @Description:
// @param err
// @return code
// @return msg
func ParseGrpcError(err error) (code common.BusinessCode, msg string) {
	fromError, _ := status.FromError(err)
	code = common.BusinessCode(fromError.Code())
	msg = fromError.Message()
	return code, msg
}
